VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "ResourceEnumerator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Declare Function EnumResourceNames Lib "kernel32" Alias "EnumResourceNamesA" (ByVal hModule As Long, lpType As Any, ByVal lpEnumFunc As Long, LParam As ListBox) As Long
Private Declare Function lstrlenOfLPSTR Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Const RT_CURSOR = 1&
Private Const RT_BITMAP = 2&
Private Const RT_ICON = 3&
Private Const RT_MENU = 4&
Private Const RT_DIALOG = 5&
Private Const RT_STRING = 6&
Private Const RT_FONTDIR = 7&
Private Const RT_FONT = 8&
Private Const RT_ACCELERATOR = 9&
Private Const RT_RCDATA = 10&

Private m_CallBack As CallBack

Public Function EnumResNameProc(ByVal hModule As Long, ByVal lpszType As Long, ByVal lpszName As Long, LParam As ListBox) As Long
Dim iLen As Long
Dim strTmp As String
    iLen = lstrlenOfLPSTR(lpszName)
    If iLen Then
        strTmp = String$(iLen, 0)
        CopyMemory ByVal strTmp, ByVal lpszName, iLen
        LParam.AddItem strTmp
    Else
        LParam.AddItem lpszName
    End If
    EnumResNameProc = 1
End Function

Public Sub FillListWithStringIds(DllName As String, LB As ListBox)
Dim hModule As Long
Dim ResType As Long
    hModule = LoadLibrary(DllName)
    If hModule Then
        LB.Clear
        ResType = RT_STRING
        EnumResourceNames hModule, ByVal ResType, m_CallBack.ProcAddress, LB
        FreeLibrary hModule
    Else
        Beep
    End If
End Sub

Private Sub Class_Initialize()
    Set m_CallBack = NewCallBack(CBType_ENUMRESNAMEPROC, Me, True)
End Sub

